﻿using Albatross.Modules;
using Albatross.SampleClient.ViewModels;
using Albatross.SampleClient.Views;
using Albatross.WPF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Albatross.SampleClient {
	public class Module : IModule {
		public const string ShellMenuItem_ResourceKey = "shell menu item";
		static ResourceDictionary Resource;
		static Module() {
			Resource = (ResourceDictionary)Application.LoadComponent(new Uri("/Albatross.SampleClient;component/Views/ShellMenu.xaml", UriKind.RelativeOrAbsolute));
		}

		public string Name { get { return "Albatross Sample Client"; } }
		public void Init(object param) {
			ViewLocator.Instance.Register<TestViewModel, TestView>();
			ViewLocator.Instance.Register<Composite1ViewModel, Composite1View>();
			ViewLocator.Instance.Register<Composite2ViewModel, Composite2View>();
			ViewLocator.Instance.Register<CompositeMainViewModel, CompositeMainView>();
			ViewLocator.Instance.Register<ContactsViewModel, ContactsCompositeView>();
			ViewLocator.Instance.Register<ContactViewModel, ContactView>();
		}

		public void Load(object param) {
			Menu menu = (Menu)param;
			MenuItem item = (MenuItem)Resource[ShellMenuItem_ResourceKey];
			if (!menu.Items.Contains(item)) {
				menu.Items.Add(item);
			}
		}

		public void Unload(object param) {
			Menu menu = (Menu)param;
			MenuItem item = (MenuItem)Resource[ShellMenuItem_ResourceKey];
			if (menu.Items.Contains(item)) {
				menu.Items.Remove(item);
			}
		}
	}
}
